package com.yxb.appointment.mapper;

import java.util.List;
import com.yxb.appointment.domain.MyAppointment;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 我的预约Mapper接口
 * 
 * @author 林德炫
 * @date 2025-03-29
 */
public interface MyAppointmentMapper 
{
    /**
     * 查询我的预约
     * 
     * @param appointmentId 我的预约主键
     * @return 我的预约
     */
    public MyAppointment selectMyAppointmentByAppointmentId(Long appointmentId);

    /**
     * 查询我的预约列表
     * 
     * @param myAppointment 我的预约
     * @return 我的预约集合
     */
    public List<MyAppointment> selectMyAppointmentList(MyAppointment myAppointment);

    /**
     * 新增我的预约
     * 
     * @param myAppointment 我的预约
     * @return 结果
     */
    public int insertMyAppointment(MyAppointment myAppointment);

    /**
     * 修改我的预约
     * 
     * @param myAppointment 我的预约
     * @return 结果
     */
    public int updateMyAppointment(MyAppointment myAppointment);

    /**
     * 删除我的预约
     * 
     * @param appointmentId 我的预约主键
     * @return 结果
     */
    public int deleteMyAppointmentByAppointmentId(Long appointmentId);

    /**
     * 批量删除我的预约
     * 
     * @param appointmentIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteMyAppointmentByAppointmentIds(Long[] appointmentIds);

    @Select("select * from my_appointment where parent_name = #{parentName} and (#{status} is null or status = #{status})")
    List<MyAppointment> getListByParentName(@Param("parentName") String parentName, @Param("status") String status);

    @Select("select * from my_appointment where teacher_name = #{teacherName} and (#{status} is null or status = #{status})")
    List<MyAppointment> getListByTeacherName(@Param("teacherName") String teacherName, @Param("status") String status);

    @Update("update my_appointment set status = 'approved' where appointment_id = #{appointmentId}")
    Boolean confirmAppointment(Long appointmentId);
}
